FROM node:20-alpine

WORKDIR /app
ENV NODE_ENV=production

# 先装依赖（无锁文件场景）
COPY package*.json ./
RUN npm install --omit=dev --registry=https://registry.npmmirror.com

# 再拷贝源码
COPY . .

# 端口与健康检查
ENV PORT=3000
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://127.0.0.1:${PORT}/_health || exit 1

CMD ["node", "server.js"]
